/** COPYRIGHT(C) 2008. Loc Phan. All Rights Reserved.
    A program that change the blackest and whitest pixel
    to yellow.
    with various methods.
    @author Loc Phan
    @version 1.01 2008-11-05
*/

import java.awt.Color;

public class HighlightExtremes
{
   public static void main(String[] args)
   {
      final int THRESHOLD = 50;
      
      Picture original = new Picture("butterfly1.jpg");
      Picture modified = new Picture("butterfly1.jpg");
      
      int stop = modified.getWidth()-1;
      double whiteDistance = 0;
      double blackDistance = 0;

      
      int height = modified.getHeight();
      
      for(int x = 0; x<stop;x++)
      {
         for(int y = 0; y<height;y++)
         {
            modified.getPixel(x, y);
            whiteDistance = Pixel.colorDistance(modified.getPixel(x, y).getColor(), Color.white);
            blackDistance = Pixel.colorDistance(modified.getPixel(x, y).getColor(), Color.black);

            
            if(Math.abs(whiteDistance)<THRESHOLD || Math.abs(blackDistance)<THRESHOLD)
            {
               modified.getPixel(x, y).setColor(Color.yellow);
             
            }
            
         }
      }
      
      original.show();
      modified.show();
    }
}

